//
//  motor.h
//  Embedded_System
//
//  Created by Edward Bassan on 2/26/14.
//  Copyright (c) 2014 Edward Bassan. All rights reserved.
//

#ifndef Embedded_System_motor_h
#define Embedded_System_motor_h

/*******************************
 * motor.h
 * Winter-Spring 2014
 * University of Washington Tacoma
 * Instructor: Prof. Mobus
 * Project Team:
 * Kevin Smith
 * Irving Estrera
 * Edward Bassan
 *******************************/

/*******************************
 * This file will contain constants and header
 * information to be used with the robot
 * vehicle senior project.
 *******************************/

/*******************************
 * The Raspberry Pi pinout has
 * pin 2 is closest to the physical
 * corner of the board.  This uses all
 * 17 available pins on the Pi
 *******************************/

/* Left motor pins */
#define LEFT_MOTOR_PWR	 ;
#define LEFT_MOTOR_INA	 ;
#define LEFT_MOTOR_INB	 ;
#define LEFT_MOTOR_ENA	 ;
#define LEFT_MOTOR_ENB	 ;

/* Right motor pins */
#define RIGHT_MOTOR_PWR	 ;
#define RIGHT_MOTOR_INA	 ;
#define RIGHT_MOTOR_INB	 ;
#define RIGHT_MOTOR_ENA	 ;
#define RIGHT_MOTOR_ENB	 ;

/* Sonar and SPI pins */
#define MULTIPLEX_S0	 ;
#define MULTIPLEX_S1	 ;
#define	MULTIPLEX_S2	 ;
#define SPI_MOSI	 ;
#define SPI_MISO	 ;
#define SPI_CLK	 ;
#define SPI_CS0	 ;
#define LEFT_ENCODER_PULSES 3165
#define RIGHT_ENCODER_PULSES 731
#define ON 1
#define OFF 0



typedef struct motor {
    
    
    //member functions
    int(*moveRight)(struct motor *);
    int(*moveLeft)(struct motor *);
    int(*moveForward)(struct motor *);
    int(*moveBack)(struct motor *);
        
    int(*setLeftMotorPwr)(struct motor *, int pin, int state);
    int(*setRightMotorPwr)(struct motor *, int pin, int state);
    int(*setLeftDirMotor)(struct motor *, int pin, int dir);
    int(*setRightDirMotor)(struct motor *, int pin, int dir);
    int(*setLeftMotorSpeed)(struct motor *, int pin, int speed, int pid);
    int(*setRightMotorSpeed)(struct motor *, int pin, int speed, int pid);

    
}motorStr;

typedef motorStr * MotorPtr;


//motor functions
MotorPtr newMotorConstructor(void);
int setLeftMotorPwr(MotorPtr this,int pin, int on);
int setRightMotorPwr(MotorPtr this, int pin, int on);
int setLeftDirMotor(MotorPtr this, int pin, int dir);
int setRightDirMotor(MotorPtr this, int pin, int dir);
int setLeftMotorSpeed(MotorPtr this, int pin, int speed, int pid);
int setRightMotorSpeed(MotorPtr this, int pin, int speed, int pid);
int moveRight(MotorPtr this);
int moveLeft(MotorPtr this);
int moveForward(MotorPtr this);
int moveBack(MotorPtr this);





#endif
